package test1;
/**
 * Created by burns.
 *
 * @author <a href="http://www.esoon-soft.com/">burns</a>
 * @date 2021/03/30 16:45
 */

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.Factory;

/**
 * TODO
 *
 * @ClassName HelloWorld
 * @Author Burns
 * @DAte 2021/3/30 16:45
 */
public class HelloWorld {
    public static void main(String[] args){

        Factory<SecurityManager> f= new IniSecurityManagerFactory("classpath:TestShiro.ini");
        SecurityManager s = f.getInstance();
        SecurityUtils.setSecurityManager(s);

        UsernamePasswordToken token = new UsernamePasswordToken("javass","cc");
        token.setRememberMe(true);

        Subject currentUser = SecurityUtils.getSubject();
        currentUser.login(token);

        boolean flag = currentUser.isPermitted("p1");

        System.out.println("flag == "+ flag);
    }
}
